package src.twice;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class UnZipTextFileFrame extends JFrame{

//    private JTable table;
//
//    protected void do_unzipButton_actionPerformed(ActionEvent args){
//        DefaultTableModel model = (DefaultTableModel) table.getModel();
//        model.setColumnIdentifiers(new Object[]{"序号","文件名"});
//        int id = 1;
//        ZipFile zf = null;
//
//        zf = new ZipFile(zipFile);
//        Enumeration e = zf.entries();
//        while (e.hasMoreElements()){
//            ZipEntry entry = (ZipEntry) e.nextElement();
//            if(!entry.getName().endsWith(".txt")){
//                continue;
//            }
//
//            File currentFile = new File(targetFile+File.separator+entry.getName());
//            try {
//                FileOutputStream out = new FileOutputStream(currentFile);
//                InputStream in = zf.getInputStream(entry);
//                int buffer = 0;
//                while ((buffer=in.read())!=-1){
//                    out.write(buffer);
//                }
//                model.addRow(new Object[]{id++,currentFile.getName()});
//                in.close();
//                out.close();
//            } catch (FileNotFoundException ex) {
//                throw new RuntimeException(ex);
//            } catch (IOException ex) {
//                throw new RuntimeException(ex);
//            }
//        }
//        table.setModel(model);
//        JOptionPane.showMessageDialog(this,"解压缩完成");
//    }
}
